package book.controller;

import book.service.IBookService;
import com.xuan.bkm.constants.RespCode;
import com.xuan.bkm.dto.HttpResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/api/book")
@Api(value = "图书测试接口")
public class BookController {
    @Value("${server.port}")
    private int port;
    @Autowired
    private IBookService ibs;

    @GetMapping("/findAll")
    @ApiOperation("图书查询模块")
    public HttpResp findAll(){
        return new HttpResp.Builder()
                .code(RespCode.FIND_BOOK_SUCCESS.getCode())
                .msg(RespCode.FIND_BOOK_SUCCESS.getName()+"port:"+port)
                .results(ibs.findAll())
                .time(LocalDateTime.now())
                .builder();
    }
}
